#include<iostream>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<string>
#include<iterator>
#include<algorithm>
#include<ctype.h>
#include<bits/stdc++.h>
#define BHUSHAN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define vi vector<ll>
#define vip vector<pair<ll,ll>>
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
using namespace std;
ll factorial(ll n){return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);}
ll max(ll a,ll b){if(a>b)return a;return b;}
void inputv(vector<ll>&v,ll n){for(ll i=0;i<n;i++){ll x;cin>>x;v.push_back(x);}return;}
void coutv(vector<ll>v){for(ll i=0;i<v.size();i++)cout<<v[i]<<" ";cout<<endl;return;}
bool isPowerOfTwo(ll n){if(n==0)return false;return (ceil(log2(n)) == floor(log2(n)));}
bool isPrime(ll n){if (n <= 1)return false;for (int i = 2; i <= sqrt(n); i++)if (n % i == 0)return false;return true;}
int gcd(int a, int b){if (a == 0)return b;return gcd(b % a, a);}ll ceil_div(ll a, ll b) {return a % b == 0 ? a / b : a / b + 1;}
ll mex(vector<ll>v){ll ans=-1;unordered_map<ll,ll>mp;for(ll i=0;i<v.size();i++)mp[v[i]]++;for(ll i=0;i<=v.size();i++){if(mp[i]==0)return i;}}
bool isSorted(vector<ll>v){ ll n=v.size();vector<ll>s;s=v;sort(s.begin(),s.end());for(ll i=0;i<n;i++){if(s[i]!=v[i]){return false;}}return true;}
//***************************************START YOUR CODE FROM HERE******************************************//
// vector<ll>ans;
ll mod=1000000000+7;
int main()
{
ll T;
cin>>T;
while((T--))
{
ll n;
cin>>n;
ll zero=0;
vector<ll>v;
for(ll i=0;i<n;i++)
{
ll x;
cin>>x;
if(x==0)
zero++;
else
v.push_back(x);
}
if(zero==n)
cout<<"NO"<<endl;
else
{
sort(v.begin(),v.end());
vector<ll>ans;
while(zero--)
ans.push_back(0);
ll sum=0;
ll l=0,r=v.size()-1;
while(l<=r)
{
if(sum>=0)
{
ans.push_back(v[l]);
sum+=v[l];
l++;
}
else
{
ans.push_back(v[r]);
sum+=v[r];
r--;
}
}
cout<<"YES"<<endl;
for(auto i:ans)
cout<<i<<" ";
cout<<endl;
}
}
return 0;
}
6. Zigzag Conversion | 1612B - Special Permutation |
1481. Least Number of Unique Integers after K Removals | 1035. Uncrossed Lines |
328. Odd Even Linked List | 1219. Path with Maximum Gold |
1268. Search Suggestions System | 841. Keys and Rooms |
152. Maximum Product Subarray | 337. House Robber III |
869. Reordered Power of 2 | 1593C - Save More Mice |
1217. Minimum Cost to Move Chips to The Same Position | 347. Top K Frequent Elements |
1503. Last Moment Before All Ants Fall Out of a Plank | 430. Flatten a Multilevel Doubly Linked List |
1290. Convert Binary Number in a Linked List to Integer | 1525. Number of Good Ways to Split a String |
72. Edit Distance | 563. Binary Tree Tilt |
1306. Jump Game III | 236. Lowest Common Ancestor of a Binary Tree |
790. Domino and Tromino Tiling | 878. Nth Magical Number |
2099. Find Subsequence of Length K With the Largest Sum | 1608A - Find Array |
416. Partition Equal Subset Sum | 1446. Consecutive Characters |
1618A - Polycarp and Sums of Subsequences | 1618B - Missing Bigram |